package com.thermofisher.dsc.amanda.common.excel.model;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.metadata.BaseRowModel;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

/**
 * Created by wenjie.yang on 4/3/2019.
 */
@Getter
@Setter
@Table(name = "eone_customer_cache")
public class E1Customer extends BaseRowModel implements Validate{
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;


  @ExcelProperty(index = 1)
  @Column(name = "st_no")
  private String ship2NO;

  @ExcelProperty(index = 2)
  @Column(name = "alpha_name")
  private String ship2AlphaName;

  @ExcelProperty(index = 0)
  @Column(name = "bt_no")
  private String bill2NO;

  @ExcelProperty(index = 17)
  @Column(name = "bt_lab_dept")
  private String bill2MailingName;

  @ExcelProperty(index = 13)
  @Column(name = "first_name")
  private String firstName;

  @ExcelProperty(index = 14)
  @Column(name = "last_name")
  private String lastName;

  @ExcelProperty(index = 12)
  @Column(name = "email")
  private String email;


  @Override
  public String toString() {
    return "E1Customer{" +
        "ship2NO='" + ship2NO + '\'' +
        ", ship2AlphaName='" + ship2AlphaName + '\'' +
        ", bill2NO='" + bill2NO + '\'' +
        ", bill2MailingName='" + bill2MailingName + '\'' +
        '}';
  }

  @Override
  public boolean validate() {
    if (StringUtils.isBlank(this.ship2NO)&&StringUtils.isBlank(this.bill2NO)&&StringUtils.isBlank(this.email)){
      return false;
    }
    return true;
  }
}
